package com.five.welcome.dao;

import com.five.welcome.entity.Dormitoryallocation;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.welcome.entity.statistic.RoomOfStudentCount;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ywt
 * @since 2024-07-12
 */
@Mapper
public interface DormitoryallocationMapper extends BaseMapper<Dormitoryallocation> {

    @Insert("insert into dormitoryallocation (s_number,s_name,building_number,dormitory_number, bed_number, location) VALUES " +
            "(#{sNumber},#{sName},#{buildingNo},#{dormitoryNumber},#{bedNo},#{location})")
    void giveRoom(String sNumber, String sName,int buildingNo, int dormitoryNumber, int bedNo,String location);

    @Select("SELECT location,count(*) as total FROM dormitoryallocation GROUP BY location")
    List<RoomOfStudentCount> RoomOfStudentCount();

    @Insert("insert into dormitoryallocation (s_number, s_name) VALUES " +
            "(#{sNumber},#{sName})")
    int addRoom(String sNumber, String sName);
}
